import { h } from 'vue';
import { Select } from 'ant-design-vue';
const canNotRepeatOptions = [
  {
    label: '不允许重复',
    value: 1,
  },
  {
    label: '无',
    value: 0,
  },
];
const canNotEmptyOptions = [
  {
    label: '无',
    value: 0,
  },
  {
    label: '不允许为空',
    value: 1,
  },
  {
    label: '为空则过滤掉',
    value: 2,
  },
];
export const mainColumns: any[] = [
  {
    title: '列名',
    dataIndex: 'title',
    align: 'center',
  },
  {
    title: '字段名',
    dataIndex: 'name',
    align: 'center',
  },
  {
    title: '规则',
    dataIndex: 'canNotRepeat',
    align: 'center',
    customRender: ({ text, record }) => {
      return h(Select, {
        value: text,
        options: canNotRepeatOptions,
        style: 'width:100%',
        onChange: (value) => {
          record['canNotRepeat'] = value;
        },
      });
    },
  },
  {
    title: '空值',
    dataIndex: 'canNotEmpty',
    align: 'center',
    customRender: ({ text, record }) => {
      return h(Select, {
        value: text,
        options: canNotEmptyOptions,
        style: 'width:100%',
        onChange: (value) => {
          record['canNotEmpty'] = value;
        },
      });
    },
  },
];

export const childColumns: any[] = [
  {
    title: '名称',
    dataIndex: 'name',
    align: 'center',
  },
  {
    title: '值',
    dataIndex: 'value',
    align: 'center',
  },
  {
    title: '对应的名称',
    dataIndex: 'otherVal',
    align: 'center',
    width: 200,
  },
];
